package com.fengchao.util.encrypt;

import com.fengchao.util.common.ByteTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.security.MessageDigest;

/**
 * Created by wangnian on 2016/6/3.
 */
public class Md5 {
    private static Logger logger = LoggerFactory.getLogger(Md5.class);

    public static String encoderToString(String str, String key) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            String string = str + key;
            String strMd5 = ByteTools.parseByte2HexStr(md5.digest(string.getBytes("utf-8")));
            return strMd5;
        } catch (Exception ex) {
            logger.warn("exception:{}", ex);
        }
        return null;
    }
}
